<?php
include( "inc/header.php" );
switch ( $_GET['Action'] )
{
case "logout" :
    addlog( "退出系统", $_SESSION['user_name'] );
    session_unset( );
    session_destroy( );
    header( "Location: Admin_Login.php" );
default :
    if ( $_SESSION['admin'] == "ok" )
    {
        header( "Location: Admin_Index.php" );
    }
    if ( $_POST['name'] && $_POST['password'] )
    {
        $db->query( "SELECT * FROM tun2_adminset where name='".str_check( $_POST['name'] )."' and password='".md5( md5( $_POST['password'] ) )."'" );
        if ( 0 < $db->next_record( ) )
        {
            $_SESSION['user_name'] = $_POST['name'];
            $_SESSION['uid'] = $db->Record['id'];
            $_SESSION['admin'] = "ok";
            if ( function_exists( "date_default_timezone_set" ) )
            {
                date_default_timezone_set( "Hongkong" );
            }
            $db->query( "UPDATE tun2_adminset SET lasttime='".date( "Y-m-d H:i:s" )."',lastip='".getip( )."' where name='".str_check( $_POST['name'] )."'" );
            addlog( "登陆成功", $_SESSION['user_name'] );
            header( "Location: Admin_Index.php" );
        }
        else
        {
            session_unset( );
            session_destroy( );
            work_back( "管理员、密码不正确！正在返回.....", "Admin_Login.php" );
            exit( );
        }
    }
    echo "<style type=\"text/css\">\r\n<!--\r\nbody {\r\n\tbackground:url(images/idmax_bg1.gif) top repeat-x;\r\n\tmargin:0px;\r\n\t}\r\ntd {\r\n\tcolor:#666; font-size:12px;\r\n}\r\n.table {\r\n\tborder: 0px;background:#fff;\r\n}\r\n.input {border:1px solid #82b2c7;background-color:#FFFFFF;line-height:19px;padding-left:10px;height:19px;width:138px;font-size: 12px;background-image: url(images/input_bg_29.gif);\r\n}\r\n-->\r\n</style>\r\n<script language=javascript>\r\nfunction isok(theform)\r\n{\r\n\tif (theform.name.value==\"\")\r\n  {\r\n\talert(\" 用户名不能为空！\");\r\n\ttheform.name.focus();\r\n\treturn (false);\r\n  }\r\nif (theform.password.value==\"\")\r\n  {\r\n\talert(\"对不起!密码不能为空！\");\r\n\ttheform.password.focus();\r\n\treturn (false);\r\n  }\r\nreturn (true);\r\n}\r\n</script>\r\n  <table width=\"700\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" >\r\n    <tr>\r\n      <td><table width=\"100%\"  height=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n        <tr>\r\n            <td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n\t\t\t\t<form action=\"Admin_Login.php\" method=\"post\" name=\"theform\" onSubmit=\"return isok(this)\">\r\n                <tr>\r\n                  \r\n                  <td width=\"290\" height=\"300\" style=\"background:url('images/idmax_bg4.gif')  right no-repeat;padding-right:20px;\"><img src=\"images/logo.gif\" alt=\"企业网站管理系统\" /><br/>
</td>\r\n                  <td width=\"350\"><table width=\"300\"height=\"160\"  align=\"center\" cellpadding=\"0\" cellspacing=\"0\"style=\"background:#f6fbff;border:1px solid #cce4f0;text-align:center\">\r\n                      <tr>\r\n                        <td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n                            <tr>\r\n                              <td height=\"30\">用户名:&nbsp;&nbsp;&nbsp;\r\n                                  <input name=\"name\" type=\"text\" class=\"input\" id=\"name\" size=\"20\" /></td>\r\n                            </tr>\r\n                            <tr>\r\n                              <td height=\"30\">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;&nbsp;&nbsp;\r\n                                  <input name=\"password\" type=\"password\" class=\"input\" id=\"password\" size=\"20\" /></td>\r\n                            </tr>\r\n                            <tr>\r\n                              <td height=\"30\"><input name=\"Submit_Login\" type=\"Submit\" id=\"Submit_Login\" value=\"登  录\" style=\"border:0;padding:0 15px;cursor:pointer;height:1.8em;color:#fff;background:#40b6f6;overflow:visible;\"/></td>\r\n                            </tr>\r\n                        </table></td>\r\n                     \r\n                      </tr>\r\n                  </table></td>\r\n                  <td width=\"1\" bgcolor=\"#FFFFFF\"></td>\r\n                </tr>\r\n\t\t\t</form>\r\n            </table></td>\r\n          </tr>\r\n      </table></td>\r\n    </tr>\r\n    <tr>\r\n      <td height=\"33\" align=\"center\"><hr color=\"#CCE4EE\"><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:10px;\">Powered by <strong>泸州北方化学工业有限公司</strong> Network&copy; 2006-2009 <a href=\"http://www.028gc.com\" target=\"_blank\"><strong><font color=\"#ff3300\">028gc</font>.Com</strong></a></font></td>\r\n    </tr>\r\n  </table>\r\n";
}
?>
